package handle;

import common.Constants.ServiceConstant;
import common.Result;
import dataBean.CourseInfoDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import service.CourseService;
import service.VerifyService;

/**
 * Created by lxl on 2015/11/5.
 */
@Controller
@RequestMapping("ssms/add")
public class AddCourseHandle {

    @Autowired
    private CourseService courseService ;

    @Autowired
    private VerifyService verifyService ;


    @RequestMapping( value = ("/course") , method = RequestMethod.POST)
    public @ResponseBody
    Result process( @RequestBody CourseInfoDo courseInfoDo , @RequestHeader String token ){

        Result result = verifyService.verify(token, ServiceConstant.ADMIN_LEVEL) ;

        if( result.isSucces() ){

            result = courseService.addCourse(courseInfoDo) ;

        }

        return result ;

    }


}
